home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 541 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: altair.dur.ac.uk!d3g3gw
  2. From: Nick Pratt <N.B.Pratt@durham.ac.uk>
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: C Code prob
  5. Date: Mon, 8 Jan 1996 21:46:54 +0000
  6. Organization: University of Durham, Durham, UK.
  7. Message-ID: <Pine.SOL.3.91-941213.960108214431.23338A-100000@altair.dur.ac.uk>
  8. NNTP-Posting-Host: altair.dur.ac.uk
  9. Mime-Version: 1.0
  10. Content-Type: TEXT/PLAIN; charset=US-ASCII
  11.  
  12.  
  13. Could anyone help me with this please:
  14.  
  15. Im trying to code a get around for a program originally coded in MS-DOS 
  16. Turbo C using cprint(). Im tryint to port this prog to my Amiga using the 
  17. curses.lib. However, curses.lib does not print \r control codes, so I 
  18. tried the following:
  19. void cprintf(const char *fmt, ... )
  20. {
  21.     char c, newfmt[4096];
  22.     int i=0, j=0, len;
  23.     va_list ap;
  24.         
  25.     va_start(ap,fmt);
  26.  
  27.     len = strlen(fmt);
  28.     
  29.     while( len > (j-1) )
  30.     {
  31.         c = fmt[j++];
  32.     
  33.         if( c == '\r' ) /* Discard any \r's */
  34.             continue;
  35.     
  36.         newfmt[i++] = c; /* Otherwise, copy the char to the new array */
  37.     }
  38.  
  39.     /* printw() is out of curses.lib, and doesnt convert \r */
  40.     printw(newfmt, ?????? );
  41.  
  42.     /* What I now need to do is call printw() with the format string of
  43.        newfmt, and also with all the arguments supplied to cprintf();
  44.  
  45.        Whats the best way to do this?
  46.      */
  47.     
  48.     
  49.     va_end(ap);
  50.     
  51.     return;
  52. }
  53.  
  54.  
  55. I can easily remove the \r from the fmt string, but I now need to call 
  56. printw() with the newfmt string and with all the arguments in the var 
  57. args list. Any ideas?
  58.  
  59. Please crosspost to email as well,
  60.  
  61. Cheers,
  62.  
  63. Nick
  64.  
  65.  
  66. +-----------------------------------------------------------------------------+
  67. |      PGP Key Available: Email with REQUEST PGP as subject                |
  68. |      HTTP://www.dur.ac.uk/~d3g3gw         FIDO: 2:250/602.1                |
  69. +-----------------------------------------------------------------------------+
  70.  
  71.